package com.qboot.websocket.controller;

import com.qboot.common.entity.Result;
import com.qboot.websocket.service.WebSocketService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * WebSocket
 *
 * @author Tellsea
 * @date 2023/2/11
 */
@Api(tags = "WebSocket")
@RestController
@RequestMapping("/webSocket")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class WebSocketController {

    private final WebSocketService webSocketService;

    @ApiOperation("服务端发送到客户端")
    @GetMapping("/sendServerToClient/{userId}/{message}")
    public Result sendServerToClient(@PathVariable("userId") String userId, @PathVariable("message") String message) {
        return webSocketService.sendServerToClient(userId, message);
    }
}
